﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Kaiser.Modules.Mis.Repositories;
using Kaiser.Modules.Mis.Models;
using Kaiser.Models;


namespace Kaiser.Modules.Mis.Services.Impl
{
    public class BookManageService : IBookManageService
    {
        private readonly IBookRepository _repository;

        public BookManageService(IBookRepository repository)
        {
            _repository = repository;
        }

        public void InsertBook(Models.BookInput model)
        {
            try
            {
                _repository.InsertBook(model);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public DataGrid<BookInput> SearchBook(BookSearch search, PagingInfo pageInfo)
        {
            try
            {
                return _repository.SearchBook(search, pageInfo);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public void InsertCategory(Models.CategoryInput model)
        {
            try
            {
                _repository.InsertCategory(model);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public void InsertPublisher(Models.PublisherInput model)
        {
            try
            {
                _repository.InsertPublisher(model);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public void UpdateBook(Models.BookInput model)
        {
            try
            {
                  _repository.UpdateBook(model);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public void UpdateCategory(Models.CategoryInput model)
        {
            try
            {
                _repository.UpdateCateogry(model);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public void UpdatePublisher(Models.PublisherInput model)
        {
            try
            {
                _repository.UpdatePublisher(model);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }


        public DataGrid<CategoryInput> SearchCategroy(CategorySearch search, PagingInfo pageinfo)
        {
            try
            {
                return _repository.SearchCategory(search, pageinfo);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public DataGrid<CategoryInput> GetCategoryTreeList(CategorySearch search, PagingInfo pageinfo)
        {
            try
            {
                return _repository.GetCategoryTreeList(search, pageinfo);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }


        public int DeleteBookList(string ids)
        {
            try
            {
                return _repository.DeleteBookList(ids);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public int DeletePublisherList(string ids)
        {
            try
            {
                return _repository.DeletePublisherList(ids);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public int DeleteCategoryList(string ids)
        {
            try
            {
                return _repository.DeleteCategoryList(ids);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }


        public DataGrid<PublisherInput> SearchPublisher(PublisherSearch search, PagingInfo pageinfo)
        {
            try
            {
                return _repository.SearchPublisher(search, pageinfo);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}
